//
//  TimeMsgCell.m
//  ChangChat
//
//  Created by Cocoa on 2019/8/23.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "TimeMsgCell.h"
#import "NSDate+Debug.h"

@implementation TimeMsgCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.timeLabel = [KKPaddingLabel new];
    self.timeLabel.k_fontSize(12).k_textColor(UIColor.whiteColor);
    self.timeLabel.backgroundColor = UIColor.k_hexColor(0xaaaaaa);
    self.timeLabel.padding = UIEdgeInsetsMake(3, 5, 3, 5);
    self.timeLabel.k_cornerRadius(3.0f);
    
    [self.msgContentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.msgContentView);
        make.top.mas_offset(5);
        make.bottom.mas_offset(-5);
    }];
    
    [self.msgContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(Chat_MsgContent_MaxWidth);
    }];
    self.iconImgView.hidden = YES;
    
    self.timeLabel.text = arc4random()%2==0 ? @"10:30" : @"2019:11:30 10:30";
    
}

- (void)setMsgModel:(MsgModel *)msgModel {
    [super setMsgModel:msgModel];
    
    self.timeLabel.text = [NSDate yyyy_MM_ddOrMM_ddWithTimestamp:msgModel.msg.createtime];
}

@end
